<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <meta http-equiv="X-UA-Compatible" content="ie=edge" />
    <title>Document</title>
    <style>
      input {
        color: #999;
      }
    </style>
  </head>

  <body>
    <input type="text" value="手机" />
    <script>
      // 获取元素
      var ipt = document.querySelector("input");
      // 获取焦点事件
      ipt.onfocus = function () {
        if (this.value === "手机") {
          this.value = "";
        }
        this.style.color = "#333";
      };
      // 失去焦点事件
      ipt.onblur = function () {
        if (this.value === "") {
          this.value = "手机";
        }
        this.style.color = "#999";
      };
    </script>
  </body>
</html>
